/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张宇田
 * Date: 2025-08-19
 * Time: 17:55
 */
import java.util.ArrayList;
import java.util.List;

public class Test {

    public List<List<Integer>> generate (int row){
        List<List<Integer>> ret = new ArrayList<>();

        //0.
        List<Integer> list0 = new ArrayList<>();
        list0.add(1);
        ret.add(list0);


        for (int i = 1; i < row; i++){
            List<Integer> tmp = new ArrayList<>() ;

            //1.
            tmp.add(1);

            List<Integer> prevRow = ret.get(i-1);
            //mid  j小于当前行的长度
            for(int j = 1 ; j<i;j++){
                tmp.add(prevRow.get(j-1) + prevRow.get(j));

            }

            //end
            tmp.add(1);

            ret.add(tmp);
        }


        return ret;
    }
}
